#ifndef DATABASEEXPLORERMODEL_H
#define DATABASEEXPLORERMODEL_H

#include <QAbstractItemModel>
#include <client/dbclient.h>
using namespace mongo;

class Node{
public:
    enum Type{
        Root,Connection,User,Database,Collection,Index,Javascript,GridFS,Document
    };
    Node(Type type,const QString &str="");
    ~Node();
    //DBClientConnection* clientConnection;
    Type type;
    QString str;
    Node* parent;
    QList<Node* > children;

};

class DatabaseExplorerModel : public QAbstractItemModel
{
public:
    DatabaseExplorerModel(QObject* parent=0);
    ~DatabaseExplorerModel();

    QModelIndex index(int row, int column, const QModelIndex &parent) const;

    QModelIndex parent(const QModelIndex &child) const;

    int rowCount(const QModelIndex &parent) const;

    int columnCount(const QModelIndex &parent) const;

    QVariant data(const QModelIndex &index, int role) const;

    QVariant headerData(int section, Qt::Orientation orientation, int role) const;

    void buildChildNodes(Node* root,DBClientConnection& clientConnection);

    Node* nodeFromIndex(const QModelIndex& index) const;

private:
    Node* rootNode;
};

#endif // DATABASEEXPLORERMODEL_H
